// login/pages/login/login.js
import { login } from '../../../api/index'
import Toast from '@vant/weapp/toast/toast';
Page({

  /**
   * 页面的初始数据
   */
  data: {
    username: '',
    password: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  async login() {
    //登录的逻辑
    console.log(111);
    let result = await login(this.data)
    if (result.data.code == 200) {
      Toast.success(result.data.msg);
      wx.setStorageSync('token', result.data.token);
      setTimeout(() => {
        wx.navigateBack()
      }, 2000);
    } else {
      Toast.fail(result.data.msg);
    }

  },
  registe() {
    //注册
    wx.navigateTo({
      url: '../registe/registe',
    })
  },
  onClickLeft() {
    //左上角导航按钮
   wx.switchTab({
     url: '/pages/mine/mine',
   })
  }
})